
local M=_G.ServerOHOH.class.new(script,  _G.ServerOHOH.files.Server_PlayerComponent(),script.Parent.Name);

local tool=require(script.Parent.tool)

function M.new(self,...)
	return M(self,...);
end;

function M.ctor(self, parent)
	M.super.ctor(self, parent);	

    self.player=self.parent
    self.DataBase=self.player:GetComponent(_G.ServerOHOH.load.Server_PlayerDataComponent());

    self.player.CanNotRobuxBuyEvent:Connect(function(gid,gtype,...)
        if gtype=="fristPackage" then
            local isCanBuy= tool.IsCanBuy(gid,gtype,self.DataBase)
            return  isCanBuy
        end
    end)

    
    self.player.RobuxBuyDoneEvent:Connect(function(gid,gtype,...)
        if gtype=="fristPackage" then
            self.DataBase:GetData("sate").fristPackage=true
            local data=tool.GetPackData()
            self.player:GetComponent(_G.ServerOHOH.load.Server_ItemCtrl()):AddItem(data)
            self.parent:SynchDataToClient("sate")
        end
    end)

end;

function M.dtor(self)
	M.super.dtor(self);
end;


return M